#include<stdio.h>
int main()
{
	int a=0, b=0;
	int t = 0;
	scanf_s("%d %d", &a, &b);
	while (t = a % b)
	{
		b=a;
		a = t;
	}
	printf("%d\n", a);
	return 0;
}